<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="org.huqiwen.blog.data.MessageDataBean"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>我的博客</title>
<link type="text/css" href="skin/default/css/index.css" rel="stylesheet" />
<link type="text/css" href="skin/default/css/blogMessage.css" rel="stylesheet"/>
<script type="text/javascript" src="js/verify.js"></script>

<jsp:useBean id="message" class="org.huqiwen.blog.logic.MessageLogicBean"></jsp:useBean>
<% String str_curPage= request.getParameter("curPage");
	if(str_curPage!=null){
		message.setCurPage(Integer.parseInt(str_curPage));
	}
	int allPage = message.getAllPage();
	int allRows = message.getAllRows();
	int pageSize = message.getPageSize();
	int curPage = message.getCurPage();	
	List<MessageDataBean> list = message.findAll();
	
	String username = (String)session.getAttribute("username");
%>
</head>	
<body>
	<div id="container">
	<jsp:include page="head.jsp"/>
		<div id="msgList">
		<h4>留言列表</h4>
		<hr />
			<%if(list.size()!=0){
				for(int i=0;i<list.size();i++){
					MessageDataBean bean = (MessageDataBean)list.get(i);%>	
			<span class="title"><%=bean.getMsgId()%>&nbsp;&nbsp;<%=bean.getMsgTitle()%></span>
			<%if(username!=null){ %>
			<span>｜<a href="MessageActionServlet?method=delMessage&id=<%=bean.getMsgId()%>">删除</a></span>
			<%} %>
			<div>作者：<%=bean.getMsgName()%> &nbsp;日期：<%=bean.getMsgDate()%></div>
			<div class="content"><%=bean.getMsgContent()%></div>
			<hr />
		<%}}%>
		<span　class="paging">
			<%if(curPage!=1){%>
				<a href="Message.jsp?curPage=1">首页</a>
				<a href="Message.jsp?curPage=<%=curPage-1%>">上一页</a>
			<%}if(curPage!=message.getAllPage()){%>
				<a href="Message.jsp?curPage=<%=curPage+1%>">下一页</a>
				<a href="Message.jsp?curPage=<%=message.getAllPage()%>">末页</a>
			<%} %>
			</span>
		</div>
		<div id="message">
		<h4>发表留言：</h4>
			<form  action="MessageActionServlet?method=addMessage" name="message" method="post">
			<table>			
				<tr>
					<td>标题： </td>
					<td><input type="text" name="title" id="title"/><span>(必填)</span></td>
				</tr>
				<tr>
					<td>姓名：</td>
					<td><input type="text" name="name" id="name"/><span>(选填)</span></td>
				</tr> 
				<tr>
					<td>内容：</td>
					<td><textarea cols="40" rows="6" name="content" id="content"></textarea></td>
				</tr>
				<tr>
					<td></td>
					<td><input type="button" class="combtn" value="发表留言" onclick="messageCheck()"/></td>
				</tr>
			</table>
			
			</form>
		</div>
		<%@include file="foot.jsp"%>
	</div>
</body>
</html>

